package com.ewzj.bigdata.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.ewzj.bigdata.mvp.model.entity.resbean.SearchResult;
import com.ewzj.bigdata.mvp.ui.adapter.SearchResultAdapter;
import com.jess.arms.di.scope.ActivityScope;

import dagger.Module;
import dagger.Provides;

import com.ewzj.bigdata.mvp.contract.SearchContract;
import com.ewzj.bigdata.mvp.model.SearchModel;

import java.util.ArrayList;
import java.util.List;


@Module
public class SearchModule {
    private SearchContract.View view;

    /**
     * 构建SearchModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public SearchModule(SearchContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    SearchContract.View provideSearchView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    SearchContract.Model provideSearchModel(SearchModel model) {
        return model;
    }

    @Provides
    RecyclerView.LayoutManager provideLayoutManager() {
        return new LinearLayoutManager(view.getActivity());
    }
    @ActivityScope
    @Provides
    List<SearchResult> provideSearchResultList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    RecyclerView.Adapter provideSearchResultAdapter(List<SearchResult> results){
        return new SearchResultAdapter(results);
    }

}